#include "excepthandlerType.h"
#include "IVisitor.h"

excepthandlerType::excepthandlerType(const exprTypePtr& type, const exprTypePtr& name, const StmtTypeList& body, int nodeId):
    SimpleNode(nodeId),
    _type(type),
    _name(name),
    _body(body)
{
}
    
excepthandlerType::~excepthandlerType()
{
    _body.clear();
}
    
QString excepthandlerType::type() const
{
    return "excepthandlerType";
}
    

exprTypePtr excepthandlerType::type_()
{
    return _type;
}

void excepthandlerType::setType_(const exprTypePtr& type)
{
    _type = type;
}

exprTypePtr excepthandlerType::name()
{
    return _name;
}

void excepthandlerType::setName(const exprTypePtr& name)
{
    _name = name;
}

StmtTypeList excepthandlerType::body()
{
    return _body;
}

void excepthandlerType::setBody(const StmtTypeList& body)
{
    _body = body;
}

    
QString excepthandlerType::toString() const
{
    return QString("excepthandlerType[type=%1, name=%2, body=%3]").
                arg(_type ? _type->toString():"").
                arg(_name ? _name->toString():"").
                arg(_body.toString());
}
    
void excepthandlerType::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    traverse(visitor);
}
    
void excepthandlerType::traverse(IVisitor* visitor)
{
    if (_type != NULL)
        _type->accept(visitor, _type);
    if (_name != NULL)
        _name->accept(visitor, _name);
    _body.traverse(visitor);
}